package com.itlong.cloud.property.resource;

import com.itlong.cloud.POJO.DTO.app.APPServiceGetRepairListDTO;
import com.itlong.cloud.POJO.DTO.app.APPServiceUploadRepairDTO;
import com.itlong.cloud.POJO.DTO.property.PropertyRepairGetRepairsByPageDTO;
import com.itlong.cloud.POJO.DTO.property.PropertyRepairHandleDTO;
import com.itlong.cloud.POJO.PO.RepairProcessPO;
import com.itlong.cloud.POJO.VO.app.AppRepairDetailVO;
import com.itlong.cloud.POJO.VO.property.PropertyRepairGetOneVO;
import com.itlong.cloud.POJO.VO.property.PropertyRepairGetRepairsByPageVO;
import com.itlong.cloud.noncore.property.IPropertyRepairManageClient;
import com.itlong.cloud.property.service.IPropertyRepairManageService;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <desc>
 *     物业-物业报修管理暴露接口实现类
 * </desc>
 *
 * @createDate 2018/08/09
 */
@RestController
public class PropertyRepairManageServiceResource implements IPropertyRepairManageClient {

    @Autowired
    private IPropertyRepairManageService iPropertyRepairManageService;

    /**
     * <desc>
     *      提交物业报修申请
     * </desc>
     *
     * @param appServiceUploadRepairDTO 提交物业报修申请参数
     * @return 添加条数
     * @author wangzhi
     * @createDate 2018/08/09
     */
    @Override
    @PostMapping(path = "app/repair/uploadRepair")
    public Integer uploadRepair(@RequestBody APPServiceUploadRepairDTO appServiceUploadRepairDTO) throws Exception {
        return iPropertyRepairManageService.uploadRepair(appServiceUploadRepairDTO);
    }

    /**
     * <desc>
     *      获取当天已有的流水号
     * </desc>
     *
     * @param timeNum 当天的时间
     * @return 流水号集合
     * @author wangzhi
     * @createDate 2018/08/10
     */
    @Override
    @PostMapping(path = "app/repair/getRepairNums")
    public List<String> getRepairNums(@RequestParam("timeNum") String timeNum) throws Exception {
        return iPropertyRepairManageService.getRepairNums(timeNum);
    }

    /**
     * <desc>
     *      获取我的物业报修数据
     * </desc>
     *
     * @param appServiceGetRepairListDTO 获取我的物业报修数据请求参数
     * @return 结果集
     * @author wangzhi
     * @createDate 2018/08/10
     */
    @Override
    @PostMapping(path = "app/repair/getRepairList")
    public List<RepairProcessPO> getRepairList(@RequestBody APPServiceGetRepairListDTO appServiceGetRepairListDTO) throws Exception {
        return iPropertyRepairManageService.getRepairList(appServiceGetRepairListDTO);
    }

    /**
     * <desc>
     *      获取我的报修详情
     * </desc>
     *
     * @param messageId 报修数据id
     * @return 报修管理实体对象
     * @author wangzhi
     * @createDate 2018/08/10
     */
    @Override
    @PostMapping(path = "app/repair/getRepairDetail")
    public AppRepairDetailVO getRepairDetail(@RequestParam("messageId") String messageId) throws Exception {
        return iPropertyRepairManageService.getRepairDetail(messageId);
    }

    /**
     * <desc>
     *      操作报修数据
     * </desc>
     *
     * @param messageId 报修数据id
     * @param managerType 操作类型
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2018/08/13
     */
    @Override
    @PostMapping(path = "app/repair/repairManager")
    public Integer repairManager(@RequestParam("messageId") String messageId, @RequestParam("managerType") String managerType) throws Exception{
        return iPropertyRepairManageService.repairManager(messageId,managerType);
    }

    /**
     * <desc>
     *       分页获取报修管理信息，包含待受理、已受理、已完成、已取消
     * </desc>
     *
     * @param propertyRepairGetRepairsByPageDTO 查询参数
     * @return 分页数据
     * @author wangzhi
     * @createDate 2018/08/14
     */
    @Override
    @PostMapping(path = "property/repair/getRepairsByPage")
    public Page<PropertyRepairGetRepairsByPageVO> getRepairsByPage(@RequestBody PropertyRepairGetRepairsByPageDTO propertyRepairGetRepairsByPageDTO) throws Exception {
        return iPropertyRepairManageService.getRepairsByPage(propertyRepairGetRepairsByPageDTO);
    }

    /**
     * <desc>
     *      获取单个报修信息
     * </desc>
     *
     * @param repairId 报修id
     * @return 单个报修信息对象
     * @author wangzhi
     * @createDate 2018/08/14
     */
    @Override
    @PostMapping(path = "property/repair/getOneRepair")
    public PropertyRepairGetOneVO getOneRepair(@RequestParam("repairId") String repairId) {
        return iPropertyRepairManageService.getOneRepair(repairId);
    }

    /**
     * <desc>
     *      待受理页面处理操作
     * </desc>
     *
     * @param propertyRepairHandleDTO 报修信息各流程处理DTO
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2018/08/15
     */
    @Override
    @PostMapping(path = "property/repair/acceptRepair")
    public Integer acceptRepair(@RequestBody PropertyRepairHandleDTO propertyRepairHandleDTO) throws Exception {
        return iPropertyRepairManageService.acceptRepair(propertyRepairHandleDTO);
    }

    /**
     * <desc>
     *      已受理页面撤销操作
     * </desc>
     *
     * @param propertyRepairHandleDTO 报修信息各流程处理DTO
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2018/08/15
     */
    @Override
    @PostMapping(path = "property/repair/cancelRepair")
    public Integer cancelRepair(@RequestBody PropertyRepairHandleDTO propertyRepairHandleDTO) throws Exception {
        return iPropertyRepairManageService.cancelRepair(propertyRepairHandleDTO);
    }

    /**
     * <desc>
     *      已受理页面完成操作
     * </desc>
     *
     * @param propertyRepairHandleDTO 报修信息各流程处理DTO
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2018/08/15
     */
    @Override
    @PostMapping(path = "property/repair/completeRepair")
    public Integer completeRepair(@RequestBody PropertyRepairHandleDTO propertyRepairHandleDTO) throws Exception {
        return iPropertyRepairManageService.completeRepair(propertyRepairHandleDTO);
    }

    /**
     * <desc>
     *      确认返修操作
     * </desc>
     *
     * @param propertyRepairHandleDTO 报修信息各流程处理DTO
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2018/08/15
     */
    @Override
    @PostMapping(path = "property/repair/reworkRepair")
    public Integer reworkRepair(@RequestBody PropertyRepairHandleDTO propertyRepairHandleDTO) throws Exception {
        return iPropertyRepairManageService.reworkRepair(propertyRepairHandleDTO);
    }

    /**
     * <desc>
     *      批量删除
     * </desc>
     *
     * @param repairIds 报修id，多个用英文","相连
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2018/08/15
     */
    @Override
    @PostMapping(path = "property/repair/deleteRepairs")
    public Integer deleteRepairs(@RequestParam("repairIds") String repairIds) throws Exception {
        return iPropertyRepairManageService.deleteRepairs(repairIds);
    }

    /**
     * <desc>
     *      依条件获取所有报修数据
     * </desc>
     *
     * @param propertyRepairGetRepairsByPageDTO 查询参数
     * @return 所有报修数据
     * @author wangzhi
     * @createDate 2018/08/16
     */
    @Override
    @PostMapping(path = "property/repair/getAllRepairs")
    public List<PropertyRepairGetRepairsByPageVO> getAllRepairs(@RequestBody PropertyRepairGetRepairsByPageDTO propertyRepairGetRepairsByPageDTO) throws Exception {
        return iPropertyRepairManageService.getAllRepairs(propertyRepairGetRepairsByPageDTO);
    }
}
